import sys
import time
import unittest
from report.HTMLTestRunner import HTMLTestRunner

sys.path.append('C:/Users/Billjc/PycharmProjects/pyrequest-rxd/interface')

''' 指定测试用例为当前文件夹下的 interface 目录'''
test_dir = 'C:/Users/Billjc/PycharmProjects/pyrequest-rxd/interface'
# discover = unittest.defaultTestLoader.discover(test_dir, pattern='*_Test.py')
discover = unittest.defaultTestLoader.discover(test_dir, pattern='home_rate_test.py')

if __name__ == "__main__":
    now = time.strftime("%Y%m%d_%H%M%S")
    filename = 'C:/Users/Billjc/PycharmProjects/pyrequest-rxd/report/' + now + '_result.html'
    fp = open(filename, 'wb')
    runner = HTMLTestRunner(stream=fp,
                            title='个贷系统接口测试报告',
                            description='用例执行结果明细: ')
    runner.run(discover)
    fp.close()
